package com.sy.shiro;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;


@Slf4j
@Data
public class CachedUser implements Serializable{
    private static final long serialVersionUID = -8415390949117162350L;
    private Long userId;
    private String userRefId;
    private String openId;
    private String appId;
    private long ttl;

    private Long objId;
    private Long memberId;
    private String memberType;
    private String objType;

    private JSONObject jsonObject = new JSONObject();

    //User user;

    public static final String redisTokenPrefix = "sso.token.";
    public static final String tokenCookieName = "X-AUTH-TOKEN";
    public boolean isApp() {
        return StringUtils.isNotBlank(appId);
    }
    public boolean verify(String token) {
        return verify(token, appId, userRefId, ttl);
    }
    public static boolean verify(String token, String appId, String userRefId, long ttl) {
        try {
            //long ttl = TokenUtil.DEFAULT_TTL;
            /*String e = TokenUtil.genToken(appId, userRefId, ttl);
            if (!e.equals(token)) {
                log.error("Wrong token {} expected {}: user {}", new Object[]{token, e, userRefId});
                return false;
            } else if (System.currentTimeMillis() > ttl) {
                log.error("Token has expired: " + ttl);
                return false;
            } else {
                return true;
            }*/
        } catch (Exception var3) {
            log.error("", var3);
            return false;
        }
        return false;
    }
}
